# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=isl
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.22.1
pkgrel=1
pkgdesc="Library for manipulating sets and relations of integer points bounded by linear constraints (mingw-w64)"
arch=('any')
url="https://isl.gforge.inria.fr/"
#depends=("${MINGW_PACKAGE_PREFIX}-gmp")
makedepends=("${MINGW_PACKAGE_PREFIX}-gmp")
options=('staticlibs')
license=('MIT')
source=("http://isl.gforge.inria.fr/${_realname}-${pkgver}.tar.xz"
        isl-0.14.1-no-undefined.patch)
sha256sums=('28658ce0f0bdb95b51fd2eb15df24211c53284f6ca2ac5e897acc3169e55b60f'
            '83655a7202f0a0dcce1782d4b365252bf1ad12a522b7ad82ab578ee5ec46433b')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/isl-0.14.1-no-undefined.patch
  autoreconf -fi
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --enable-static \
    --disable-shared \
    --with-gmp-prefix=${MINGW_PREFIX}

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
